package com.ranjiaqi.homework;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @ClassName Test2
 * @Description TODO
 * @Author hp
 * @Date 2021/6/23 18:23
 * @Version 1.0
 **/
public class Test2 {
    public static void main(String[] args) {
        List<Car> carList = new ArrayList<Car>();
        carList.add(new Car("奔驰",9999999));
        carList.add(new Car("宝马",9999999));
        carList.add(new Car("保时捷",9999999));
        carList.add(new Car("劳斯莱斯",9999999));
        carList.add(new Car("玛莎拉蒂",9999999));
        System.out.println(carList);
        Iterator<Car> iterator = carList.iterator();
        while (iterator.hasNext()){
            iterator.next().setMoney(10000);
        }
        iterator = carList.iterator();
        while (iterator.hasNext()){
            System.out.println("iterator.next() = " + iterator.next());
        }

    }
}
